package com.tc.gateway.tunnel;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.UnknownHostException;

import com.tc.serial.SerialStream;

public class TcpTunnelClient implements  TunnelClient {
	String ip;

	public TcpTunnelClient(String ip, short port) throws IOException {
		super();
		this.ip = ip;
		this.port = port;

			s = new Socket();
			s.connect(new InetSocketAddress(ip, port),3000);
		
	}

	short port;

	Socket s;


	public void ClosePort() {
		// TODO Auto-generated method stub

	}


	/* (non-Javadoc)
	 * @see com.tc.zigbee.tunnel.TunnelClient#getInputStream()
	 */
	public InputStream getInputStream() {

		try {
			return s.getInputStream();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}


	/* (non-Javadoc)
	 * @see com.tc.zigbee.tunnel.TunnelClient#getOutputStream()
	 */
	public OutputStream getOutputStream() {
		try {
			return s.getOutputStream();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	static public void main(String[] s) {
		try
		{
			TcpTunnelClient t = new TcpTunnelClient("127.0.0.1", (short)8888);
			t.getOutputStream().write(0);

	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	}
}
